import scrapy
from sh.items import ShItem,ShItem1

class HotSpider(scrapy.Spider):
    name = 'hot'
    # allowed_domains = ['hot.com']
    start_urls = ['https://hot.online.sh.cn/node/node_65634.htm']

    def parse(self, response):

        news_list = response.css('div.list_main div')
        for news in news_list:
            items = ShItem1()
            items['title'] = news.xpath('./h2/a/text()').extract_first()
            items['times'] = news.xpath('./h3/text()').extract_first()
            yield items
        print(response.url)
        # 翻页 多页提取
        next = response.xpath('//center/a[text()="下一页"]/@href').extract_first()
        if next:
            yield scrapy.Request('https://hot.online.sh.cn/node/' + next,callback=self.parse)



